﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.Regions;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Renci.iRods.Studio.Common;
using Microsoft.Practices.ServiceLocation;

namespace Renci.iRods.Studio.Modules.Explorer.ViewModels
{
    public class ExplorerRibbonTabViewModel
    {
        private ICommand _showExplorerCommand;
        public ICommand ShowExplorerCommand
        {
            get
            {
                if (this._showExplorerCommand == null)
                {
                    this._showExplorerCommand = new RelayCommand(() => { this.ShowExplorer(); });
                }
                return this._showExplorerCommand;
            }
        }

        private ICommand _showObjectPropertiesCommand;
        public ICommand ShowPropertiesCommand
        {
            get
            {
                if (this._showObjectPropertiesCommand == null)
                {
                    this._showObjectPropertiesCommand = new RelayCommand(() => { this.ShowObjectProperties(); });
                }
                return this._showObjectPropertiesCommand;
            }
        }

        private ICommand _showMetadataCommand;
        public ICommand ShowMetadataCommand
        {
            get
            {
                if (this._showMetadataCommand == null)
                {
                    this._showMetadataCommand = new RelayCommand(() => { this.ShowObjectMetadata(); });
                }
                return this._showMetadataCommand;
            }
        }

        private ICommand _showUsersCommand;
        public ICommand ShowUsersCommand
        {
            get
            {
                if (this._showUsersCommand == null)
                {
                    this._showUsersCommand = new RelayCommand(() => { this.ShowUsersMetadata(); });
                }
                return this._showUsersCommand;
            }
        }

        private void ShowExplorer()
        {
            var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

            regionManager.RequestNavigate(RegionNames.Left, new Uri("ExplorerDockableView", UriKind.Relative));
        }

        private void ShowObjectProperties()
        {
            var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

            regionManager.RequestNavigate(RegionNames.Right, new Uri("PropertiesDockableView", UriKind.Relative));
        }

        private void ShowObjectMetadata()
        {
            var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

            regionManager.RequestNavigate(RegionNames.Right, new Uri("MetadataDockableView", UriKind.Relative));
        }

        private void ShowUsersMetadata()
        {
            var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

            regionManager.RequestNavigate(RegionNames.Left, new Uri("UsersDockableView", UriKind.Relative));
        }
    }
}
